/**
 * 
 */
package com.sci.web.action.datareportseason.strategy;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import com.sci.web.action.util.BaseAction;
import com.sci.web.dao.DataReportM_InnovateBaseDao;

/**
 * @author BaiFuyou
 * @date: Nov 10, 2011 9:50:51 PM
 */
public class DeleteStrategyBrandManagementAction extends BaseAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = -7356602376584486361L;
	private int pid;
	private int eid;
	private int flag;
	@Resource
	private DataReportM_InnovateBaseDao dataReportM_InnovateBaseDao;

	/**
	 * @return the pid
	 */
	public int getPid() {
		return pid;
	}

	/**
	 * @param pid
	 *            the pid to set
	 */
	public void setPid(int pid) {
		this.pid = pid;
	}

	/**
	 * @return the eid
	 */
	public int getEid() {
		return eid;
	}

	/**
	 * @param eid
	 *            the eid to set
	 */
	public void setEid(int eid) {
		this.eid = eid;
	}

	/**
	 * @return the flag
	 */
	public int getFlag() {
		return flag;
	}

	/**
	 * @param flag
	 *            the flag to set
	 */
	public void setFlag(int flag) {
		this.flag = flag;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		super.setContentType(super.JSON);
		Map<String, Object> map = new HashMap<String, Object>();
		if (flag == 3) {
			map.put("brand_id", pid);
			map.put("enterprise_id", eid);
			if (dataReportM_InnovateBaseDao.deleteOneEnterprise_BrandData(map)) {
				map.clear();
				super.outPrint("ok");
			} else {
				map.clear();
				super.outPrint("fail");
			}
		} else if (flag == 2) {
			map.put("management_id", pid);
			map.put("enterprise_id", eid);
			if (dataReportM_InnovateBaseDao.deleteOneEnterprise_ManagementData(map)) {
				map.clear();
				super.outPrint("ok");
			} else {
				map.clear();
				super.outPrint("fail");
			}
		}else if(flag == 4){
			map.put("innovation_id", pid);
			map.put("enterprise_id", eid);
			if(dataReportM_InnovateBaseDao.deleteOneEnterprise_InnovationByMap(map)){
				map.clear();
				super.outPrint("ok");
				return "json";
			}else{
				map.clear();
				return "json";
			}
			
		} else if (flag == 1) {
			map.put("strategy_id", pid);
			map.put("enterprise_id", eid);
			if (dataReportM_InnovateBaseDao.deleteOneEnterprise_StrategyByid(map)) {
				map.clear();
				super.outPrint("ok");
			}else{
				map.clear();
				super.outPrint("fail");
			}			
		} else {
			map.clear();
			super.outPrint("fail");
		}
		return "json";
	}
}
